import axios from 'axios'
import request from '../utils/request'

export const LoginAPI = (data) => {
  return request.post('/v1_0/authorizations', data)
}

// 封装获取用户基本信息API

export const getUserInfoAPI = () => {
  return request.get('/v1_0/user')
}

// 封装获取用户简介信息的API
// delete请求类似于get请求体,没有请求体,只有请求头
export const getUserProfileAPI = () => {
  return request.get('/v1_0/user/profile')
}

// 封装获取修改用户简介API(姓名)
// patch,put类似于post请求 都有请求体
export const updateUserProfileAPI = (obj) => {
  return request.patch('/v1_0/user/profile', obj)
}

// 封装修改头像API
export const updateUserAvatarAPI = (fd) => {
  return request.patch('/v1_0/user/photo', fd)
}

// 封装更换token的API
export const exchangeTokenAPI = (refreshToken) => {
  return axios({
    method: 'PUT',
    url: 'http://toutiao-app.itheima.net/v1_0/authorizations',
    headers: {
      Authorization: `Bearer ${refreshToken}`
    }
  })
}
